﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Ideaa.Web.App_Start;
using DomainModels = Ideaa.Domain.Models;
using PersistedModels = Ideaa.Data.Models;
using AutoMapper;

namespace Ideaa.Tests.Mappings
{
    [TestClass]
    public class DataLayerMappingsTests
    {
        [TestInitialize]
        public void SetUp()
        {
            // Act
            AutoMapperConfig.Configure();
        }

        [TestMethod]
        public void Idea_DomainToPersistedMapping_Test()
        {
            // Arrange
            DomainModels.Idea.Idea domainModel = new DomainModels.Idea.Idea(
                new Guid().ToString(),
                "Some title",
                "Some Content");

            // Act
            var persistedModel = Mapper.Map<PersistedModels.Idea>(domainModel);

            // Assert
            Assert.IsNotNull(persistedModel.Title);
            Assert.IsNotNull(persistedModel.UserId);
        }

        [TestMethod]
        public void Suggestion_DomainToPersistedMapping_Test()
        {
            // Arrange
            DomainModels.Idea.Suggestion domainModel = new DomainModels.Idea.Suggestion(
                new Guid().ToString(),
                "Some title",
                "SOme content",
                1);

            // Act
            var persistedModel = Mapper.Map<PersistedModels.Suggestion>(domainModel);

            // Assert
            Assert.IsNotNull(persistedModel.Title);
            Assert.IsNotNull(persistedModel.UserId);
        }

        [TestMethod]
        public void Idea_PersistedToDomainMapping_Test()
        {
            // Arrange
            PersistedModels.Idea persistedModel = new PersistedModels.Idea()
            {
                Title = "TItle",
                Content = "Content",
                UserId = new Guid().ToString()
            };

            // Act
            var domainModel = Mapper.Map<DomainModels.Idea.Idea>(persistedModel);

            // Assert
            Assert.IsNotNull(domainModel.Title);
            Assert.IsNotNull(domainModel.CreatedUserId);
        }

        [TestMethod]
        public void Suggestion_PersistedToDomainMapping_Test()
        {
            // Arrange
            PersistedModels.Suggestion persistedModel = new PersistedModels.Suggestion()
            {
                Title = "TItle",
                Content = "Content",
                UserId = new Guid().ToString()
            };

            // Act
            var domainModel = Mapper.Map<DomainModels.Idea.Suggestion>(persistedModel);

            // Assert
            Assert.IsNotNull(domainModel.Title);
            Assert.IsNotNull(domainModel.CreatedUserId);
        }
    }
}
